/**
 * Created by hp on 2017/9/17.
 */


/*
 *
 * 弹框
 * 自动关闭的
 * */
function layui_alert(srt){
    layer.open({
        content: srt//
        ,yes: function(index, layero){
            layer.close(index);
        }
        ,time:2
    });
}

function layui_tishi(srt){
    layer.open({
        content: srt
        ,skin: 'msg'
        ,time: 2 //2秒后自动关闭
    });
}
/*
 *
 * 弹框
 * 自动关闭 - 刷新
 * */
function layui_alert_reload(srt){
    layer.open({
        content: srt//
        ,yes: function(index, layero){
            layer.close(index);
        }
        ,end:function(){
            location.reload();
        }
        ,time:2
    });
}
/*
 *
 * 弹框
 * 自动关闭 - 跳转
 * */
function layui_alert_jump(srt,url){
    layer.open({
        content: srt//
        ,yes: function(index, layero){
            layer.close(index);
            location.href = url;
        }
        ,end:function(){
            location.href = url;
        }
        ,time:2
    });
}

var ZNcopy = function(value,success,error){

    var isFunction = function (fun) {
        return typeof fun == 'function'?true:false;
    };
    if (document.execCommand) {
        var element = document.createElement('SPAN');
        element.textContent = value;
        document.body.appendChild(element);
        if (document.selection) {
            var range = document.body.createTextRange();
            range.moveToElementText(element);
            range.select();
        } else if (window.getSelection) {
            var range = document.createRange();
            range.selectNode(element);
            window.getSelection().removeAllRanges();
            window.getSelection().addRange(range);
        }
        document.execCommand('copy');
        if(arguments[1]){
            if(isFunction(arguments[1])){
                success();
            };
        }else {
            alert('复制成功')
        };
        element.remove ? element.remove() : element.removeNode(true);
    }else {
        if(arguments[2]){
            if(isFunction(arguments[2])){
                error();
            }
        }else {
            alert('复制失败')
        }
    }
};

